<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<!-- 引入外部的CSS文件 -->
		<link rel="stylesheet" href="css/reg.css" />
		<link rel="stylesheet" href="css/animate.css" />
		<script type="text/javascript" src="js/jquery-3.3.1.min.js"></script>
		
		<script type="text/javascript">
			$(function(){
				//注册按钮的实现
				$('#reg').click(function(){
					//获取请求参数
					var username = $('#username').val();
					var password = $('#password').val();
					var repassword = $('#repassword').val();
					//校验参数有效性
					var ok = true;
					if(username == ''){
						ok = false;
						alert('用户名不能为空');
// 						return;
					}
					if(password != repassword){
						ok = false;
						alert('两次密码不一致');
					}				
					//发送ajax请求
					if(ok){
						$.ajax({
							url:'/hospital/reg.do',
							type:'post',
							data:{'username':username,
								'password':password},
							success:function(result){
								if(result.status == 0){
									location.href = 'login.html';
								}else{
									alert('注册失败');
								}
							},
							error:function(){
								alert('系统繁忙,稍后再试');
							}
						})
					}
					
				})
			})
		</script>
		
	</head>
	<body>
		<div class="wrap animated bounceInRight">
			<!-- 顶部大标题 -->
			<h1>软帝云音乐后台管理</h1>
			<div class="reg">
				<h3>管理员注册</h3>
				<div class="title-line"></div>
				<!-- 登录表单 -->
				<div class="reg-form">
					<form action="">
						<div class="input-gorup">
							<span class="icon icon-user"></span>
							<input type="text" name="username" class="input-txt" id="username" placeholder="请输入用户名" />
						</div>
						<div class="input-gorup">
							<span class="icon icon-pwd"></span>
							<input type="password" name="password" id="password" class="input-txt" placeholder="请输入密码" />
						</div>
						<div class="input-gorup">
							<span class="icon icon-pwd"></span>
							<input type="password" name="repassword" id="repassword" class="input-txt" placeholder="请确认密码" />
						</div>
						<!-- 注意:在H5中button按钮若在form表单中，默认就有提交效果，
						若不要默认的提交效果，则可以加上type属性，并把值设置为button即可 -->
						<button class="btn-reg" id="reg">添加帐号</button>
					</form>
					<div class="account-link">
						<a href="login.html">返回</a>
					</div>
					<p class="copyright">&copy;By Mr.Zhou</p>
				</div>
			</div>
		</div>
		
	</body>
</html>
